/**
 * 
 */
package com.yiyunpower.test.portal.rest;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.yiyunpower.test.portal.bo.Proper;
import com.yiyunpower.test.portal.bo.Sdf;
import com.yiyunpower.test.portal.bo.TestPojo;
import com.yiyunpower.test.portal.service.TestService;

/**
 * @author jlzeng
 *
 */
@RestController
@RefreshScope
public class LoginControler {
	@Autowired
	private TestService service;
	
	@Autowired
	private Sdf crawlerConfig;
	
	@Value("logging.file")
	private String pro = "555";
	
	@Value("${custom}")
	private String config;
	
	@Autowired
	private Proper pro23;
	 @RequestMapping("/hello")
	 @ResponseBody
	    public String hello() {
		 System.out.println(service.getdas());
		 System.out.println(pro23.rewString);
		 System.out.println(config);
		 TestPojo pojoById = service.getPojoById(2);
	     return pojoById.getName();
	    }

	    @RequestMapping("/info")
	    public Map<String, String> getInfo(@RequestParam String name) {
	        Map<String, String> map = new HashMap<String, String>();
	        map.put("name", name);
	        return map;
	    }

	    @RequestMapping("/list")
	    public List<Map<String, String>> getList() {
	        List<Map<String, String>> list = new ArrayList<Map<String, String>>();
	        Map<String, String> map = null;
	        for (int i = 1; i <= 5; i++) {
	            map = new HashMap<String, String>();
	            map.put("name", "Shanhy-" + i);
	            list.add(map);
	        }
	        return list;
	    }
}
